package org.dylan.bdf.system.entity;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.dylan.security.entity.IOperation;
import org.dylan.security.entity.IResource;

@Entity
@Table(name="SYS_RESOURCE")
public class Resource extends Permission implements IResource {
	private static final long serialVersionUID = -8964894794862971454L;
	public static final String PERMISSION_TYPE_RESOURCE = "RESOURCE";
	private String url;
	private Boolean isShow;
	@ManyToOne
	@JoinColumn(name="PARENT_ID")
	private Resource parent;
	@OneToMany(mappedBy="resource",targetEntity=Operation.class)
	private List<IOperation> operations;

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Boolean getIsShow() {
		return isShow;
	}

	public void setIsShow(Boolean isShow) {
		this.isShow = isShow;
	}

	public Resource getParent() {
		return parent;
	}

	public void setParent(Resource parent) {
		this.parent = parent;
	}

	@Override
	public String getPermissionType() {
		return PERMISSION_TYPE_RESOURCE;
	}

	@Override
	public List<IOperation> getOperations() {
		return this.operations;
	}

	public void setOperations(List<IOperation> operations) {
		this.operations = operations;
	}

}
